#ifndef BOIDMANAGER_H
#define BOIDMANAGER_H

#include "BoidBase.h"

/**
 * Class BoidManager
 */
class BoidManager : Ogre::FrameListener
{
friend class BoidBase;
private:
	BoidList mBoidInstanceList;
	static BoidManager *mInstance;

public:
	/// create singleton instance.
	static void createSingleton()
	{
		mInstance = new BoidManager;
		Ogre::Root::getSingletonPtr()->addFrameListener(mInstance);
	}

	/// destroy singleton instance.
	static void destroySingleton()
	{
		Ogre::Root::getSingletonPtr()->removeFrameListener(mInstance);
		delete mInstance;
	}

	/// returns the instance of this object.
	static BoidManager *getSingletonPtr() { return mInstance; }

	/// returns the list of registered boids.
	BoidList& getBoidList() { return mBoidInstanceList; }

	/// returns a list of boids in the vicinity of a sphere.
	void getNeighborhoodBoids(BoidBase *boid, float minDistance, float maxDistance, float cosMaxAngle, BoidList &result);

	/// triggered per frame to execute boid simulation.
	bool frameStarted(const Ogre::FrameEvent& evt);

};

#endif // BOIDMANAGER_H
